// =======================产品服务动画=======================
var aIntroduce = document.querySelectorAll(".service-introduce");
window.addEventListener("scroll", function () {
    var iWindowHeight = document.documentElement.clientHeight;
    var iDisTop_1 = aIntroduce[0].getBoundingClientRect().top - iWindowHeight;
    var iDisTop_2 = aIntroduce[1].getBoundingClientRect().top - iWindowHeight;
    var iDisTop_3 = aIntroduce[2].getBoundingClientRect().top - iWindowHeight;
    if (iDisTop_1 < -50) {
        aIntroduce[0].style.animation = "slideRight 1s ease  forwards"
    } else {
        aIntroduce[0].style.animation = "none"
    }
    if (iDisTop_2 < -50) {
        aIntroduce[1].style.animation = "slideLeft 1s ease forwards"
    } else {
        aIntroduce[1].style.animation = "none"
    }
    if (iDisTop_3 < -50) {
        aIntroduce[2].style.animation = "slideRight 1s ease  forwards"
    } else {
        aIntroduce[2].style.animation = "none"
    }
})
// =======================锚点导航=======================
var oDocument = document.documentElement;
var oNavbar = document.querySelector(".navbar-category");
var isClick = true;
oNavbar.addEventListener("click", function (e) {
    if (isClick) {
        isClick = false;
        switch (e.target.getAttribute("data-index")) {
            case "0":
                startMove(oDocument, 2000, 50, IsClick)
                break;
            case "1":
                startMove(oDocument, 4350, 50, IsClick)
                break;
            case "2":
                startMove(oDocument, 5150, 50, IsClick)
                break;
            case "3":
                startMove(oDocument, 5813, 50, IsClick)
                break;
            case "4":
                isClick = true;
                break
        }
    }
})
function startMove(obj, targetTop, speed, fn) {
    var isStop = false;
    clearInterval(obj.timer);
    obj.timer = setInterval(function () {
        var currentTop = obj.scrollTop;
        var iSpeed = (targetTop - currentTop) / speed;
        iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
        obj.scrollTop = currentTop + iSpeed
        if (currentTop == targetTop) {
            isStop = true;
        }
        if (isStop) {
            clearInterval(obj.timer)
            fn();
        }
    }, 0)
}
function IsClick() {
    isClick = true;
}
// =======================swiper轮播=======================
var swiper = new Swiper('.swiper-container', {
    slidesPerView: 3,//同时显示3个slide
    slidesPerGroup: 3,//三个一组
    spaceBetween: 10,//间隔10px
    touchAngle: 60,//触发切换角度60°
    longSwipesRatio: 0.2,//滑动距离比0.2
    simulateTouch: true,//鼠标不模拟手机端触摸
    speed:500,
    autoplay: {
        delay: 3000,
        disableOnInteraction: false,
    },
    navigation: {
        nextEl: '.swiper-next',
        prevEl: '.swiper-prev',
    },
});
var oSwiper = swiper.el;
oSwiper.addEventListener("mouseover", function () {
    swiper.autoplay.stop();
})
oSwiper.addEventListener("mouseout", function () {
    swiper.autoplay.start();
})
